package xyz.lwm.lazycat.web.route;

import lombok.Data;
import xyz.lwm.lazycat.utility.PathUtil;
import xyz.lwm.lazycat.web.handle.Handler;
import xyz.lwm.lazycat.web.handle.HandlerType;

/**
 * abstract route
 *
 * @author lwm
 */
@Data
abstract class AbstractRoute implements Route {

    /**
     * 请求路径
     */
    private String path;

    /**
     * HTTP 请求方法
     */
    private HandlerType type;

    /**
     * 处理器
     */
    private Handler handler;


    protected AbstractRoute(String path, HandlerType type, Handler handler) {
        this.path = PathUtil.normalizePath(path);
        this.type = type;
        this.handler = handler;
    }

    /**
     * 获取路由的 key
     *
     * @return 路由的 key
     */
    public abstract String getKey();

}
